//
//  MKFirstTableViewCell.m
//  ManKeCartoon
//
//  Created by dllo on 15/10/16.
//  Copyright © 2015年 ManKe. All rights reserved.
//

#import "MKFirstTableViewCell.h"
#import "MKBaseHeader.h"
@implementation MKFirstTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier BigArray:(NSMutableArray *)bigArray index:(NSInteger)index
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        

        self.myMUtableArray = [[NSMutableArray alloc] init];
        
        self.myMUtableArray = bigArray;

        for (int i = 0; i < [self.myMUtableArray[index] count]; i++) {
            MKFirstModel *model = [[MKFirstModel alloc] init];
            model = [self.myMUtableArray[index] objectAtIndex:i];
            self.homeImage = [[UIImageView alloc] initWithFrame:CGRectMake(10 + i % 3 *( SCREEN_WIDTH / 3 - 5), 5 + i / 3 * (SCREEN_HEIGHT / 5  + 60), SCREEN_WIDTH / 3 - 15, SCREEN_HEIGHT / 5 + 20)];
            
            //NSLog(@"%f", self.homeImage.frame.origin.y);
            //NSLog(@"%f", self.cqHomeBT.frame.size.height);
            [self.homeImage sd_setImageWithURL:[NSURL URLWithString:model.cover_url]];
            self.topButton = [UIButton buttonWithType:UIButtonTypeCustom];

            [self.topButton setFrame:CGRectMake(10 + i % 3 *( SCREEN_WIDTH / 3 - 5), 5 + i / 3 * (SCREEN_HEIGHT / 5  + 60), SCREEN_WIDTH / 3 - 15, SCREEN_HEIGHT / 5 + 20)];
            
            if (index == 0) {
                [_topButton setTag:100+i];
            } else if (index == 2) {
                [_topButton setTag:100+i+[self.myMUtableArray[1] count]+[self.myMUtableArray[0]count]];
            }
            
            [self.contentView addSubview:self.topButton];
            [self.contentView addSubview:self.homeImage];
            self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.homeImage.frame.origin.x, self.homeImage.frame.size.height + self.homeImage.frame.origin.y , self.homeImage.frame.size.width, 20)];
            [self.titleLabel setText:model.title];
            [self.titleLabel setFont:[UIFont systemFontOfSize:15.]];
            [self.titleLabel setTextColor:[UIColor blackColor]];
            [self.contentView addSubview:self.titleLabel];
            
            self.typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.frame.origin.x, self.titleLabel.frame.size.height + self.titleLabel.frame.origin.y , self.titleLabel.frame.size.width, 15)];
            [self.typeLabel setText:model.meta_info];
            [self.typeLabel setTextColor:[UIColor grayColor]];
            [self.typeLabel setFont:[UIFont systemFontOfSize:12]];
            [self.contentView addSubview:self.typeLabel];
            
            if (model.pgv_count != nil) {
                
                self.rqLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.homeImage.frame.size.height - 12, 100, 10)];
                //NSString *likeNumber = [NSString stringWithFormat:@"❤️ %@",model.pgv_count];
                [self.rqLabel setText:[NSString stringWithFormat:@"❤️ %@",model.pgv_count]];
                [self.rqLabel setTextColor:[UIColor whiteColor]];
                [self.rqLabel setFont:[UIFont systemFontOfSize:12]];
                [self.homeImage addSubview:self.rqLabel];
                
            }

        }
        
        
    }
    return self;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
